package com.jt.www.biz.agree.controller;

import com.jt.www.biz.agree.service.ProtocolService;
import com.jt.www.domain.po.ProtocolLog;
import com.jt.www.enums.ResultEnum;
import com.jt.www.model.reps.ResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 我学保 登录协议
 *
 * @author shaoyn
 * @create 2020年2月25日
 */
@Api(value = "协议阅读日志", tags = {"PROTOCOL"}, description = "协议阅读日志")
@RestController
@RequestMapping(value = "/protocol")
public class ProtocolController {

    public static final Logger log = LoggerFactory.getLogger(ProtocolController.class);
    @Autowired
    private ProtocolService protocolService;

    @ApiOperation(value = "登录与注册", notes = "登录与注册", httpMethod = "POST")
    @PostMapping(value = "/agreeWithProtocol")
    public ResultDTO agreeWithProtocol(@RequestBody ProtocolLog protocolLog) {
        //记录日志
        if (protocolService.agreeWithProtocol(protocolLog) > 0) {
            return ResultDTO.createDefaultResult(ResultEnum.SUCCESS_0000);
        }
        return ResultDTO.createDefaultResult(ResultEnum.ERROR_9999);
    }

}
